import java.io.*;

public class Test_1 {
    public static void main(String[] args) {


        swap2(10,5);
        ioTest();
    }

    public static void swap(int a ,int b){
        System.out.printf("a=%d, b=%d",a,b);
        a =a + b;
        b = a -b;
        a =  a -b;
        System.out.printf("\na=%d, b=%d",a,b);
    }

    public static void swap2(int a, int b){
        System.out.printf("a=%d, b=%d",a,b);
        a =a^b;  //a1 = a^b
        b = b^a; //b = b^a^b
        a = a^b ; // a = a1 ^ b=  a ^ b ^a
        System.out.printf("\na=%d, b=%d",a,b);
    }

    public static void ioTest(){
        try (FileInputStream fis = new FileInputStream("/Users/let-fan/Desktop/致辞.txt");
             BufferedInputStream bis = new BufferedInputStream(fis);
             FileOutputStream fos = new FileOutputStream("/Users/let-fan/Desktop/致辞copy.txt");
             BufferedOutputStream bos = new BufferedOutputStream(fos);
        ){
            int size ;
            byte [] buf = new byte[1024];
            while ((size =bis.read(buf))!=-1){
                bos.write(buf,0,size);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
